home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Developer's Kit 1996
/
Delphi Developer's Kit 1996.iso
/
power
/
enterctl
/
entedit.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-12-22
|
2KB
|
85 lines
{
Edit control that reponds as if the <Tab> key has been pressed when an
<Enter> key is pressed, moving to the next control.
Very simple extension to the KeyPress event, this technique should work
with TDBedit as well, Useful for data entry type apps.
Less trouble than using the Keypreview function of the form to do the same
thing.
Please Use Freely.
Simon Callcott CIS: 100574, 1034
}
unit Entedit;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls;
type
TEnterEdit = class(TEdit)
private
protected
procedure KeyPress(var Key: Char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
published
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TEnterEdit]);
end;
procedure TEnterEdit.KeyPress(var Key: Char);
var
MYForm: TForm;
begin
if Key = #13 then
begin
MYForm := GetParentForm( Self );
if not (MYForm = nil ) then
SendMessage(MYForm.Handle, WM_NEXTDLGCTL, 0, 0);
Key := #0;
end;
if Key <> #0 then inherited KeyPress(Key);
end;
procedure TEnterEdit.KeyDown(var Key: Word; Shift: TShiftState);
var
MYForm: TForm;
CtlDir: Word;
begin
if (Key = VK_UP) or (Key = VK_DOWN) then
begin
MYForm := GetParentForm( Self );
if Key = VK_UP then CtlDir := 1
else CtlDir :=0;
if not (MYForm = nil ) then
SendMessage(MYForm.Handle, WM_NEXTDLGCTL, CtlDir, 0);
end
else inherited KeyDown(Key, Shift);
end;
end.